/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package administrador;

import java.util.HashMap;
import java.util.Map;

import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.view.JasperViewer;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperCompileManager;

public class Reportes {
    
Conexion conexion;
String jrxml;
Map parametros;
    
    public void Reportes(){
    }
    
        public void obtenerReporte(Conexion conexion,String jrxml,Map parametros) {
        this.conexion=conexion;
        this.jrxml=jrxml;
        this.parametros=parametros;
        
        String reportSource = "./reportes/Untitled_report_1.jrxml";
        reportSource=jrxml;
        
        try {
            //Saco la conexion
            JasperReport report = JasperCompileManager.compileReport(reportSource);
            JasperPrint print = JasperFillManager.fillReport(report, parametros, conexion.getconexion());
            
            // Exporta el informe a PDF
           // JasperExportManager.exportReportToPdfFile(print,"C://informes  JAsper/PDF's/Informe.pdf");
            
            //Para visualizar el pdf directamente desde java
            JasperViewer.viewReport(print, false);
            
        } catch (Exception e) {
            e.printStackTrace();
        } 

    }
    
    
    
    
}



